/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_GPKMeshLoadImpl_H__
#define __PQ_GPKMeshLoadImpl_H__

#include "EnginePrerequisites.h"
#include "SceneObject.h"
#include "ResourceLoader.h"


#include "OgreMeshSerializer.h"


namespace PQEngine
{
	class GPKSkeletonManualLoader
		: public Ogre::ManualResourceLoader
	{
	public:
		GPKSkeletonManualLoader(std::string path);//
		~GPKSkeletonManualLoader();

		void loadResource(Ogre::Resource* resource);
	private:
		std::string _path;
	};

	/** 
	 @remarks
		This class allows users to hook into the mesh loading process and
		modify references within the mesh as they are loading. Material and
		skeletal references can be processed using this interface which allows
		finer control over resources.
	*/
	class GPKMeshSerializerListener
		: public Ogre::MeshSerializerListener
	{
	public:
		GPKMeshSerializerListener(Ogre::String meshPath):_meshPath(meshPath){}
		~GPKMeshSerializerListener() {}
		
		///implement MeshSerializerListener virtual functions;
		void processMaterialName(Ogre::Mesh *mesh, Ogre::String *name);
		void processSkeletonName(Ogre::Mesh *mesh, Ogre::String *name);
	private:
		
	private:
		Ogre::String _meshPath;//
	};


	/** GPK mesh Loader that manual load mesh model.
        @remarks
			Use this class to load ogre mesh data from GPK.
    */
	class GPKMeshManualLoader
		: public Ogre::ManualResourceLoader
	{
	public:
		GPKMeshManualLoader(std::string path);//
		~GPKMeshManualLoader();

		void loadResource(Ogre::Resource* resource);
	private:
		std::string _path;
	};

	class GPKMeshLoadImpl
		: public SceneResourceLoadImpl
	{
	public:
		GPKMeshLoadImpl(SceneObject* sceneObject,std::string path,SceneResourceLocation loc=LOC_GPACK_ARCHIVE);
		GameObject* load();

		inline bool ok()
		{
			return _ok;
		}
	private:
		static std::map<std::string,Ogre::Mesh*> _loadedMeshes;
	private:
		bool _ok;
	};

}
#endif

